<template>
	<div>
		<el-row :gutter="20">
		  	<el-col :span="24">
				<el-card class="box-card">
					<el-form v-loading="loading" :inline="false" ref="form" :model="form" label-width="100px">
						<el-form-item label="姓名：">
							<el-input v-model="form.nickname" class="input" :disabled="true" ></el-input>
						</el-form-item>
						<el-form-item label="新密码：" prop="pwd"
			  				:rules="[
      							{ required: true, message: '密码不能为空!'}
    						]"	
			  			>
			    			<el-input v-model="form.pwd" class="input" placeholder="请输入新密码"></el-input>
			  			</el-form-item>
			  		</el-form>
				</el-card>
		  	</el-col>
		</el-row>
	</div>
</template>

<script>
    export default{
		data() {
			return {
				loading:false,
				form:{
					"userid":"",
					"nickname":"",
					"pwd":""
				}
			}
		},
		methods:{
			reset(){
				this.$refs.form.resetFields();
			},
			showInfo(userid,nickname){
                this.$refs.form.resetFields();
                this.form.userid=userid;
				this.form.nickname=nickname;
			},
			save() {
        		this.$refs['form'].validate((valid) => {
        			if (valid) {
        				this.$confirm('此操作将直接修改用户登录密码, 是否继续?', '提示', {
		          			confirmButtonText: '确定',
		          			cancelButtonText: '取消',
		          			type: 'warning'
		        		}).then(() => {
		        			this.loading=true;
	        				this.$http.post('user/modifyPassword',{
	        					"userId":this.form.userid,
								"password":this.$md5(this.form.pwd),
								"token":sessionStorage.getItem("token")
							}).then(response => {
								var data= response.body;
								if(data.code==0){
									this.reset();
							        this.$emit('dialogResult');
								}
								this.alertMsg(data.code,data.msg);
								this.loading=false;
							});
        				});
          			}
        		});
      		}
		}
	}
</script>

<style scoped="scoped">
	.input{
		width: 300px;
	}
</style>